# Overconfidence measures comparison (Table 1, Appendix A)
# ------- overconfidence tester ----
# we draw N, run a reg and save B and SE
overconfidence <- function(N, S, e) { # inputs: N (number of observations in regression), S (number of simulations), e (error variance in DGP)
betas <- rep(NA, times = length(S)) # store B's
se <- rep(NA, times = length(S)) # store SE's
for (s in 1:S) {
x <- rnorm(N)
y <- 2*x + rnorm(N, mean = 0, sd = e)
res <- lm(y ~ x)
betas[s] <- res$coefficients[2] # beta-hat
se[s] <- coef(summary(res))[2, "Std. Error"]
}
bk.num <- sqrt(sum((betas-mean(betas))^2)) # BK method
our.num <- sqrt(1/S*sum((betas - mean(betas))^2)) # ours
# ------------ for the denominator
bk.den <- sqrt(sum(se^2)) # BK method
our.den <- 1/S*sum(se) # ours
# ---------- final measures
bk <- 100*(bk.num/bk.den) # BK method
ours <- 100*(our.num/our.den) # ours (rescaled)
# print stuff:
multi.return <- list("BK overconfidence:" = bk,
"Our overconfidence:" = ours,
"Mean of SE:" = mean(se),
"SD of SE:" = sd(se),
"Mean of betas:" = mean(betas),
"SD of betas:" = sd(betas))
return(multi.return)
}
#  Table 1, Appendix A:
set.seed(1039000)
final.1 <- overconfidence(N = 100, S = 100, e = 1)
final.2 <- overconfidence(N = 100, S = 1000, e = 1)
final.3 <- overconfidence(N = 100, S = 100000, e = 1)
final.4 <- overconfidence(N = 100, S = 100, e = 10)
final.5 <- overconfidence(N = 100, S = 1000, e = 10)
final.6 <- overconfidence(N = 100, S = 100000, e = 10)
final.7 <- overconfidence(N = 25, S = 100, e = 10)
final.8 <- overconfidence(N = 25, S = 1000, e = 10)
final.9 <- overconfidence(N = 25, S = 100000, e = 10)
rbind(as.data.frame(final.1),
as.data.frame(final.2),
as.data.frame(final.3),
as.data.frame(final.4),
as.data.frame(final.5),
as.data.frame(final.6),
as.data.frame(final.7),
as.data.frame(final.8),
as.data.frame(final.9))
